Ext.define("Module.ldjscharts.TodayCharts",{
	extend : 'Ext.panel.Panel',
	border: false,
	layout:'column',
	initComponent : function() {
		var me = this;
		me.defaults = {padding:5};
		var taskSum_store = Ext.create("Ext.data.Store",{
			fields: ['name','counts'],
			autoLoad: true,
			proxy: {
				type: 'ajax',
				url: 'sjfx/LeadDrivingAction/taskSum_today.do',
				reader: {
					type: 'json',
				}
			}
		});
		var taskSum = Ext.create("Ext.panel.Panel",{
			title:'今日任务总数',
			height:300,
			layout:'fit',
			columnWidth:1/3,
			items:[{
				xtype:'chart',
				animate: true,  
				store: taskSum_store,
				theme: 'Base:gradients',
//				legend: {
//				position: 'right'
//				},
				series: [{
					type: 'pie',
					angleField: 'counts',
					showInLegend: true,
					tips: {
						trackMouse: true,
						width: 140,
						height: 35,
						renderer: function(storeItem, item) {
							// calculate and display percentage on hover
							var total = 0;
							taskSum_store.each(function(rec) {
								total += rec.get('counts');
							});
							this.setTitle(storeItem.get('name') + '总数: '+storeItem.get('counts')+ ',占 ' + Math.round(storeItem.get('counts') / total * 100) + '%');
						}
					},
					highlight: {
						segment: {
							margin: 20
						}
					},
					label: {
						field: 'name',
						display: 'rotate',
						contrast: true,
						font: '18px Arial'
					}
				}]
			}]
		});

		var videoSum_today = Ext.create("Ext.panel.Panel",{
			title:'今日视频总数',
			height:300,layout:'fit',
			columnWidth:1/3,
			items:[{
				xtype:'chart',
				height: 250,
				animate: true,
				store:  Ext.create('Ext.data.Store', {
					fields: ['counts', 'name'],
					autoLoad: true,
					proxy: {
						type: 'ajax',
						url: 'sjfx/LeadDrivingAction/videoSum_today.do',
						reader: {
							type: 'json',
						}
					}
				}),
//				legend: {
//				position: 'right'
//				},
				axes: [{
					type: 'Numeric',
					position: 'left',
//					label: {
//						renderer: Ext.util.Format.numberRenderer('0,0')
//					},
					title: '数量',
					fields:['counts'],
					grid: true,
					majorTickSteps: 4,
					minimum: 0
				},
				{
					type: 'Category',
					position: 'bottom',
					fields: ['name'],
					grid: true,
					label: {
						renderer: function(v) {
							return String(v);
						}
					},
					title: false
				}],
				series: [{
					type: 'column',
					highlight: {
						size: 7,
						radius: 7
					},
					axis: 'left',
					xField: 'name',
					yField: ['counts'],
					tips: {
						trackMouse: true,
						width: 140,
						height: 35,
						renderer: function(storeItem, item) {
							this.setTitle('数量: '+storeItem.get('counts'));
						}
					},
					markerConfig: {
						type: 'cross',
						size: 4,
						radius: 4,
						'stroke-width': 0
					}
				}]
			}]
		});


		var taskLv_today = Ext.create("Ext.panel.Panel",{
			title:'今日任务完成率',
			height:300,layout:'fit',
			columnWidth:1/3,
			items:[{
				xtype:'chart',
				height: 250,
				animate: true,
				store:  Ext.create('Ext.data.Store', {
					fields: ['lv', 'name'],
					autoLoad: true,
					proxy: {
						type: 'ajax',
						url: 'sjfx/LeadDrivingAction/taskLv_today.do',
						reader: {
							type: 'json',
						}
					}
				}),
//				legend: {
//				position: 'right'
//				},
				axes: [{
					type: 'Numeric',
					position: 'left',
//					label: {
//						renderer: Ext.util.Format.numberRenderer('00')
//					},
					title: '完成率（%）',
					//fields:['lv'],
					grid: true,
					minimum: 0,
					majorTickSteps: 4
				},
				{
					type: 'Category',
					position: 'bottom',
					fields: ['name'],
					grid: true,
					label: {
						renderer: function(v) {
							return String(v);
						}
					},
					title: false
				}],
				series: [{
					type: 'column',
					highlight: {
						size: 7,
						radius: 7
					},
					axis: 'left',
					xField: 'name',
					yField: ['lv'],
					tips: {
						trackMouse: true,
						width: 60,
						height: 35,
						renderer: function(storeItem, item) {
							this.setTitle(toFixed2(storeItem.get('lv'))+'%');
						}
					},
					markerConfig: {
						type: 'cross',
						size: 4,
						radius: 4,
						'stroke-width': 0
					}
				}]
			}]
		});
		me.items = [taskSum,videoSum_today,taskLv_today];
		me.callParent();
	}
});